package com.afd.ozblip.util;

import android.content.Context;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import android.os.Environment;
import android.telephony.TelephonyManager;

public class PhoneUtil {

	/**
	 * 获取当前网络类型
	 * 
	 * @param paramContext
	 * @return
	 */
	public static String getWebType(Context paramContext) {
		return ((ConnectivityManager) paramContext
				.getSystemService("connectivity")).getActiveNetworkInfo()
				.getTypeName();
	}

	/**
	 * 获取IMEI
	 * 
	 * @param paramContext
	 * @return
	 */
	public static String getIMEI(Context paramContext) {
		String str = "";
		try {
			str = ((TelephonyManager) paramContext.getSystemService("phone"))
					.getDeviceId();
			if (str == null) {
				str = "";
			}
		} catch (Exception localException) {
		}
		return str;
	}

	/**
	 * 判断是否存在SD卡
	 * 
	 * @return
	 */
	public static boolean hasSDCard() {
		return "mounted".equals(Environment.getExternalStorageState());
	}

	/**
	 * 获取的服务提供商名称（SPN） 。
	 * 
	 * @param paramContext
	 * @return
	 */
	public static String getSPN(Context paramContext) {
		return ((TelephonyManager) paramContext.getSystemService("phone"))
				.getSimOperatorName();
	} 

	/**
	 * 判断是否连接了网络
	 * 
	 * @param paramContext
	 * @return
	 */
	public static boolean hasNetwork(Context paramContext) {
		NetworkInfo localNetworkInfo = ((ConnectivityManager) paramContext
				.getSystemService("connectivity")).getActiveNetworkInfo();
		if (localNetworkInfo == null) {
			return false;
		} else {
			return true;
		}
	}
}
